import {axiosHttp} from "@/util/axios.ts";
import {storageHook} from "@/hooks/storagehook.ts";
import {StorageStrategy} from "@/util/storage.ts";
import {REFRESH_TOKEN_KEY, TOKEN_KEY} from "@/common/comConstant/commoncanstant.ts";

export function refreshTokenApi() {
    return axiosHttp.get("/noAuth/refreshToken")
}

export function setTokenToCookies(token: string, expirationTime: number, refreshToken: string, refreshTime: number) {
    const cookies = storageHook(StorageStrategy.COOKIE_STORAGE).storage
    cookies.setWithExpiration(TOKEN_KEY, token, expirationTime)
    cookies.setWithExpiration(REFRESH_TOKEN_KEY, refreshToken, refreshTime)
}